home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
logicsim.arc
/
LOGICSIM.INC
< prev
next >
Wrap
Text File
|
1986-01-08
|
20KB
|
1,008 lines
{ Include File for Logic Simulator }
{ APRIL 1985 }
Procedure WriteHeader;
begin
Writeln(Device); Writeln(Device);
Writeln(Device,Header);
Writeln(Device);
end;
Procedure GetQintoXQ;
begin
OLD[0]:=LNOT[OLD[Q1]]; XQ:=OLD[Q0];
end;
Procedure StoreQandNotQ;
begin
NEW[Q0]:=Y;
NEW[Q1]:=LNOT[Y];
end;
Procedure MuxFunction;
begin
Y:= (Y0 And LNOT[YC]) Or (Y1 And YC) Or (Y0 and Y1);
if Y<>0 then Y:=3;
end;
Procedure SetAndResetFunction;
begin
Y:= (Y Or LNOT[XSS]) And XR;
if Y<>0 then Y:=3;
end;
Procedure ShiftRegisterFCN;
begin
Y0:=XD; YC:=XC; Y1:=XL;
MuxFunction;
SetAndResetFunction;
YL:=Y; Y0:=XQ;
MuxFunction;
SetAndResetfunction;
end;
Procedure MuxAndDFF;
begin
Y0:= D0; Y1:= D1; YC:=XM;
MuxFunction;
XD:=Y;
ShiftRegisterFCN;
end;
Procedure AndGate;
begin
OLD[0]:=L1; Y:=L1;
for I:=1 to 5 do
begin
Y:= Y and OLD[INPUT[I]];
if Y<>0 then Y:=3;
end;
end;
Procedure NandGate;
begin
X:=Q0; Q0:=Q1; Q1:=X;
AndGate;
end;
Procedure OrGate;
begin
OLD[0]:=L0; Y:=L0;
for I:=1 to 5 do
begin
Y:= Y or OLD[INPUT[I]];
if Y<>0 then Y:=3;
end;
end;
Procedure NorGate;
begin
X:=Q0; Q0:=Q1; Q1:=X;
OrGate;
end;
Procedure XorGate;
begin
OLD[0]:=LX;
Y0:=OLD[INPUT[1]]; Y1:=LNOT[Y0]; YC:=OLD[INPUT[2]];
MuxFunction;
end;
Procedure XNorGate;
begin
X:=Q0; Q0:=Q1; Q1:=X;
XorGate;
end;
Procedure DFlipFlop;
begin
GetQintoXQ;
OLD[0]:=LX; XD:=OLD[INPUT[1]]; XC:=OLD[INPUT[3]];
XL:=LO[L,8]; OLD[0]:=L1; XR:=OLD[INPUT[4]]; XSS:=OLD[INPUT[5]];
ShiftRegisterFCN;
LO[L,8]:=YL;
end;
Procedure JKFlipFlop;
begin
GetQintoXQ;
XM:=XQ; OLD[0]:=LX; XC:=OLD[INPUT[3]];
D0:=OLD[INPUT[1]]; D1:=LNOT[OLD[INPUT[2]]];
OLD[0]:=L1; XR:=OLD[INPUT[4]];
XSS:=OLD[INPUT[5]]; XL:=LO[L,8];
MuxAndDFF;
LO[L,8]:=YL;
end;
Procedure ParallelLoadCounter;
Label DoAgain;
begin
OLD[0]:=LX; YE:=OLD[INPUT[2]]; XC:=OLD[INPUT[3]];
OLD[0]:=L0; XM:=OLD[INPUT[4]];
OLD[0]:=L1; XR:=OLD[INPUT[5]]; XSS:=L1;
DoAgain:
GetQIntoXQ;
XL:=LO[L,8];
YC:=YE; Y0:=XQ; Y1:=LNOT[Y0];
MuxFunction;
D0:=Y; DL:=OLD[INPUT[1]];
MuxAndDff;
LO[L,8]:=YL;
If TYPES[LO[L+1,0]]='*' then
begin
StoreQandNotQ;
L:=L+1; INPUT[1]:=LO[L,1]; Q0:=LO[L,6]; Q1:=LO[L,7];
YE:= YE and Y;
if YE<>0 then YE:=3;
goto DoAgain;
end;
end;
Procedure ParallelLoadShiftRegister;
Label DoAgain;
begin
OLD[0]:=LX; D0:=OLD[INPUT[2]]; XC:=OLD[INPUT[3]];
OLD[0]:=L0; XM:=OLD[INPUT[4]];
OLD[0]:=L1; XR:=OLD[INPUT[5]]; XSs:=L1;
DoAgain:
OLD[0]:=LX; D1:=OLD[INPUT[1]];
GetQintoXQ;
XL:=LO[L,8];
MuxAndDFF;
LO[L,8]:=YL;
if TYPES[LO[L+1,0]]='*' then
begin
StoreQandNotQ;
L:=L+1; INPUT[1]:=LO[L,1]; Q0:=LO[L,6]; Q1:=LO[L,7]; D0:=Y;
GOTO DoAgain;
end;
end;
Procedure NBitShiftRegister;
begin
if INPUT[2]=0 then DFlipFlop;
OLD[0]:=LX; XD:=OLD[INPUT[1]]; XC:=OLD[INPUT[3]];
OLD[0]:=L1; XR:=OLD[INPUT[4]]; XSS:=OLD[INPUT[5]];
M1:=LO[L,8];
For I:=1 to -INPUT[2] do
begin
XL:=ME[M1,0]; XQ:=ME[M1,1];
ShiftRegisterFCN;
XD:=XQ; ME[M1,0]:=YL; ME[M1,1]:=Y;
M1:=M1+1
end;
end;
Procedure SimulateThisGate;
begin
LT:=LO[L,0];
for I:=1 to 5 do
begin
INPUT[I]:=LO[L,I];
end;
Q0:=LO[L,6]; Q1:=LO[L,7];
if LT=1 then AndGate;
if LT=2 then NandGate;
if LT=3 then OrGate;
if LT=4 then NorGate;
if LT=5 then XorGate;
if LT=6 then XnorGate;
if LT=7 then DFlipFlop;
if LT=8 then JKFlipFlop;
if LT=9 then ParallelLoadCounter;
if LT=10 then ParallelLoadShiftRegister;
if LT=11 then NBitShiftRegister;
StoreQandNotQ;
end;
Procedure SimulateGates;
Label NoSim;
begin
if C9<>0 then
begin
L:=SLGIC;
repeat
if STF<>0 then if S0[L]=0 then GOTO NoSim;
SimulateThisGate;
NoSim:
L:=L+1;
until L>NLGIC;
end;
end;
Procedure LookUpSignalName;
begin
FOUND:=-1;
if Xs= ' ' then Xs:='0';
if Copy(Xs,1,1)<>'#' then
begin
for II:=0 to NNAM do
begin
if Xs= NAMES[II] then FOUND:=II;
end;
end;
if Copy(Xs,1,1)='#' then
begin
XXs:=Copy(Xs,2,length(Xs)-1);
Val(XXs,FOUND,ERROR);
FOUND:= -FOUND;
if FOUND=-1 then FOUND:=0;
end;
end; {of LookUpSignalName}
Procedure EnterChanges;
Label Change1;
begin
ClrScr;
Writeln('As each Current Sample Node is displayed, hit');
Writeln('RETURN for no change, or New Name to change.');
for I:=1 to SCREEN do
begin
Change1:
Xs:='';
Write(NAMES[SAMPLED[I]],' '); Readln(Xs);
for II:=1 to length(Xs) do
begin
Insert(UpCase(Copy(Xs,II,1)),Xs,II);
Delete(Xs,II+1,1);
end;
if Xs<>'' then
begin
LookUpSignalName;
if FOUND=-1 then GOTO Change1;
SAMPLED[I]:=FOUND;
end;
if SAMPLED[I]<>0 then NSAMPLED:=I;
end;
end;
Procedure CalcXY;
Var PXX,PYY: Real;
begin
PYY:=INT((X+XO) div LINE);
PXX:=(X+XO)-PYY*LINE;
PX:=Round(PXX)+1; PY:=Round(PYY)+1;
XO:=0;
GotoXY(PX,PY);
end;
Procedure FullScreen;
begin
TIME:=TIME-INCREMENT;
GotoXY(20,1);
Write('Change, Reset, Quit, or any other key to continue ');
Read(ASK); ASK:=ASK+' ';
ASK:=upcase(copy(ASK,1,1));
PC:=0; ClrScr;
if ASK='C' then EnterChanges;
end;
Procedure PrintTicMarks;
begin
XO:=0;
for X:=91 to 156 do
begin
CalcXY; Write('''');
end;
X:=91;
for I:=1 to 7 do
begin
CalcXY; Write(':');
XO:=5;
CalcXY; Write('|');
X:=X+10;
end;
end;
Procedure PrintValuesDownColumn;
begin
X:=PC+LINE*2;
for I:=1 to NSAMPLED do
begin
Y:=OLD[SAMPLED[I]];
CalcXY; Write(LOGPR[Y]);
X:=X+LINE;
end;
end;
Procedure SetUpDisplay;
begin
PC:=11;
ClrScr;
PrintTicMarks;
GotoXY(5,1); Write('Time');
GotoXY(12,1); Write(RI);
X:=LINE*2;
for I:=1 to NSAMPLED do
begin
CalcXY; Write(NAMES[SAMPLED[I]]);
X:=X+LINE;
end;
end;
Procedure DisplayLogicValues;
begin
GotoXY(70,0); Write(RI:8);
if TIME=RI then
begin
if PC=0 then SetUpDisplay;
PrintValuesDownColumn;
TIME:=TIME+INCREMENT;
PC:=PC+1;
if PC>LINE-4 then FullScreen;
end;
end;
Procedure ReadAndParse;
begin
if not EOF(filvar) then
begin
readln(filvar,Ls);
for I:=1 to length(Ls) do
begin
Insert(UpCase(Copy(Ls,I,1)),Ls,I);
Delete(Ls,I+1,1);
end;
LI:=0;
repeat
I:=pos(' ',Ls);
if I<>0 then
begin
LIs[LI]:= copy(Ls,1,I-1);
Ls:=copy(Ls,I,length(Ls)-I+1);
LI:=LI+1;
while copy(Ls,1,1)=' ' do Ls:=copy(Ls,2,length(Ls)-1);
end;
until I=0;
LIs[LI]:=Ls;
for I:= LI+1 to 10 do
begin
LIs[I]:=' ';
end;
end;
end; {of ReadandParse}
Procedure LookUpType;
begin
FOUND:=-1;
For II:= 0 to NTYPE-1 do
begin
if Xs= TYPES[II] then
begin
FOUND:= II;
TPTR:= TYPEX[II];
end;
end;
end; {of LookUpType}
Procedure AddType;
begin
if FOUND=-1 then
begin
FOUND:=NTYPE;
NTYPE:=NTYPE+1;
end;
if FOUND>NTYPE then NTYPE:=FOUND;
TYPES[FOUND]:=Xs;
TYPEX[FOUND]:=TPTR;
end; {of AddType}
Procedure AddNameToList;
begin
if FOUND= -1 then
begin
FOUND:= NNAM;
NNAM:= NNAM+1;
end;
if FOUND > NNAM then NNAM:= FOUND +1;
NAMES[FOUND]:= Xs;
end; {of AddNameToList}
Procedure AddT0thruT9toExternalArray;
begin
for II:=0 to 9 do
begin
EX[NE,II]:=T[II];
end;
write(Device,TEX[EX[NE,0]]:3,' ',NAMES[EX[NE,1]]:15,LOGIN[EX[NE,2]]:5);
for II:=3 to 9 do
begin
Write(Device,EX[NE,II]:5);
end;
Writeln(Device);
NE:=NE+1;
end;
Procedure AddT0thruT7toLogicArray;
begin
for II:= 0 to 7 do
begin
LO[NLGIC,II]:=T[II];
end;
Write(Device,TYPES[LO[NLGIC,0]]:10);
for II:= 1 to 7 do
begin
XX:=LO[NLGIC,II];
if XX<0 then write(Device,' #',-XX);
if XX>=0 then write(Device,NAMES[XX]:8);
end;
Writeln(Device);
NLGIC:=NLGIC+1;
end; {of AddT0thruT7toLogicArray}
Procedure ClearOldArray;
begin
for I:=0 to MNAMS do
begin
OLD[I]:=0;
end;
TL:=0;
end; {of ClearOldArray}
Procedure IgnoreErrorOption;
begin
Write('Enter (I)gnore to ignore Error');
Readln(ASK); ASK:=ASK+' ';
ASK:= upcase(copy(ASK,1,1));
if ASK<>'I' then ERROR:=1;
end; {of IgnoreErrorOption}
Procedure MultipleDefinition;
begin
Writeln('ERROR: Multiple Definition of Output ',NAMES[X]);
IgnoreErrorOption;
end; {of MultipleDefinition}
Procedure MarkOutputsAndCheckForDupes;
begin
if X<>0 then
begin
if OLD[X]<>0 then MultipleDefinition;
OLD[X]:=1;
end;
end; {of MarkOutputsAndCheckForDupes}
Procedure CheckForMultipleOutputs;
begin
X1:=STF;
for I:= X1 to NLGIC-1 do
begin
for J:= 6 to 7 do
begin
X:=LO[I,J];
MarkOutputsAndCheckForDupes;
end;
end;
end; {of CheckForMultipleOutputs}
Procedure UndefinedInput;
begin
Writeln('Undefined Input: ',NAMES[X]);
IgnoreErrorOption;
end; {of UndefinedInput}
Procedure CheckForMark;
begin
if X>0 then
begin
if OLD[X]=0 then UndefinedInput;
OLD[X]:=OLD[X]+1;
TL:=TL+1;
end;
end; {of CheckForMark}
Procedure CheckForDefinedInputs;
begin
X1:=STF;
for I:=X1 to NLGIC-1 do
begin
for J:=1 to 5 do
begin
X:=LO[I,J];
CheckForMark;
if X<0 then MM:=MM-X;
end;
end;
end; {of CheckForDefinedInputs}
Procedure MisMatch;
begin
Writeln('Mis-Match on Macro call -- Can''t Continue');
Close(Filvar);
HALT;
end;
Procedure DeleteCurrentLine;
begin
NLGIC:=NLGIC-1;
for K:=LOx to NLGIC-1 do
begin
for K1:=0 to 8 do
begin
LO[K,K1]:=LO[K+1,K1];
end;
end;
end; {of DeleteCurrentLine}
Procedure BuildMacroCorrespondenceArray;
begin
LOx:=I; X:=LO[I,0]; J:=TYPEX[X]; Y:=LO[J,0]; M1:=J; OLD[0]:=0;
Header:='Expansion of call to Macro: '+TYPES[X];
WriteHeader;
for K:=1 to MNAMS do
begin
OLD[K]:=-1;
end;
repeat
if X<>Y then MisMatch;
for K:=1 to 5 do
begin
I1:=LO[M1,K]; I2:=LO[LOx,K];
if I1=0 then if I2=0 then OLD[I1]:=I2;
if I1=0 then if I2<>0 then OLD[I1]:=I2;
if I1<>0 then if I2<>0 then OLD[I1]:=I2;
end;
for K:= 6 to 7 do
begin
I1:=LO[M1,K]; I2:=LO[LOx,K];
if I1=0 then if I2=0 then OLD[I1]:=I2;
if I1<>0 then if I2=0 then OLD[I1]:=I2;
if I1<>0 then if I2<>0 then OLD[I1]:=I2;
end;
DeleteCurrentLine;
M1:=M1+1; Y:=LO[M1,0]; X:=LO[LOx,0];
until TYPES[Y]<>'*';
end; {of BuildMacroCorrespondenceArray}
Procedure AddUniqueName;
begin
OLD[X]:=NNAM;
Str(NNAM,Xs);
NAMES[NNAM]:='&'+Xs; {Copy(Xs,2,length(Xs)-1);}
NNAM:=NNAM+1;
end; {of AddUniqueName}
Procedure AddExpandedMacroToElementArray;
begin
NLGIC:=NLGIC-1;
repeat
T[0]:=LO[M1,0];
for K:= 1 to 7 do
begin
X:=LO[M1,K];
if X<0 then T[K]:=X;
if X>=0 then
begin
if OLD[X]= -1 then AddUniqueName;
T[K]:=OLD[X];
end;
end;
AddT0thruT7toLogicArray;
M1:=M1+1;
until T[0]=0;
end; {of AddExpandedMacroToElementArray}
Procedure SetAsideMemForSregs;
begin
M1:=0;
for I:=0 to MM do
begin
ME[I,0]:=LX;
ME[I,1]:=LX;
end;
for I:=SLGIC to NLGIC do
begin
if TYPES[LO[I,0]]='SREG' then
begin
LO[I,8]:=M1;
M1:=M1-LO[I,2];
end;
end;
end;
Procedure StoreNextSchedule;
begin
EX[I,10]:=E3;
if E9>E3 then E9:=E3;
end;
Procedure InitializeForSimulation;
begin
for I:=0 to NNAM do
begin
NEW[I]:=LX;
end;
for I:=SLGIC to NLGIC do
begin
LO[I,8]:=LX;
end;
Writeln;
RI:=0;
Write('Enter Sample Start Time '); Readln(TIME);
Write('Enter Increment Time '); Readln(INCREMENT);
if INCREMENT=0 then INCREMENT:=1; PC:=0;
ClrScr;
E9:=32767;
for I:=0 to NE do
begin
E3:=EX[I,3];
StoreNextSchedule;
end;
if NSAMPLED=0 then EnterChanges;
if MM<>0 then SetAsideMemForSregs;
ASK:=' ';
end;
Procedure PrintOutLoadTable;
begin
Header:='Load Table';
WriteHeader;
Writeln(Device,'Node Driven Elements');
for II:=1 to NNAM do
begin
Write(Device,NAMES[II]:10,' ');
T1:=S1[II];
while S2[T1]<>-1 do
begin
Write(Device,S2[T1]-SLGIC+1:4);
T1:=T1+1;
end;
Writeln(Device);
end;
end;
Procedure BuildSelectiveTraceTable;
begin
STF:=1;
Writeln('***** Building Selective Trace Table');
T1:=0;
For I:=1 to NNAM do
begin
S1[I]:=T1;
For J:=SLGIC to NLGIC do
begin
For K:=1 to 5 do
begin
if LO[J,K]=I then
begin
S2[T1]:=J;
T1:=T1+1;
end;
end;
end;
S2[T1]:=-1;
T1:=T1+1;
end;
PrintOutLoadTable;
end;
Procedure FindNextChange;
Label Chng1,EndChng;
begin
E0:=EX[I,0]; E1:=EX[I,1]; E2:=EX[I,2]; E3:=EX[I,3];
Y:=NEW[E1];
if RI=E3 then Y:=LNOT[E2];
NEW[E1]:=LNOT[Y];
if TEX[E0]='P' then
begin
E3:=Ex[I,10]+EX[I,4];
GOTO EndChng;
end;
J:=4; E3:=32767;
Chng1:
if J>=9 then GOTO EndChng;
if EX[I,J]<=RI then
begin
J:=J+1;
GOTO Chng1;
end;
E3:=EX[I,J];
EndChng:
end;
Procedure GetNextScheduledExternal;
begin
if RI=E9 then
begin
E9:=32767;
for I:=0 to NE do
begin
E3:=EX[I,10];
if E3=RI then FindNextChange;
StoreNextSchedule;
end;
end
end;
Procedure ClearSO;
begin
for II:=SLGIC to NLGIC do
begin
S0[II]:=0;
end;
end;
Procedure NoteChange;
begin
C9:=1;
OLD[I]:=NEW[I];
if STF<>0 then
begin
II:=S1[I];
J:=0;
While J<>-1 do
begin
J:=S2[II];
if J<>-1 then
begin
S0[J]:=1; II:=II+1;
end;
end;
end;
end;
Procedure MoveNewToOld;
begin
C9:=0;
if STF<>0 then ClearSO;
for I:=1 to NNAM do
begin
if NEW[I]<>OLD[I] then NoteChange;
end;
end;
Procedure RecalculateRippletime;
begin
if C9=1 then RI:=RI+1;
if C9<>1 then
begin
RI:=E9;
if RI>TIME Then RI:=TIME;
end;
end;
Procedure ReadExternals;
Label BgnExt,EndExt;
begin
Header:='External Stimuli';
WriteHeader;
NE:=0;
ReadAndParse;
BgnExt:
ReadAndParse;
if LIs[0]='END' then GOTO EndExt;
for I:=0 to 1 do
begin
if LIs[0]=TEX[I] then T[0]:=I;
end;
Xs:=LIs[1];
LookUpSignalName;
if FOUND=-1 then GOTO BgnExt;
T[1]:= FOUND;
for I:= 0 to 3 do
begin
if LIs[2]=LOGIN[I] then T[2]:=LV[I];
end;
for I:=3 to 9 do
begin
val(LIs[I],T[I],J);
if J<>0 then T[I]:=0;
end;
AddT0thruT9toExternalArray;
GOTO BgnExt;
EndExt:
end; {of ReadExternals}
Procedure CheckErrors;
begin
ClearOldArray;
MM:=0;
for I:=0 to NE-1 do (*----------- this (-1) may be wrong *)
begin
OLD[EX[I,1]]:=1;
end;
STF:=SLGIC;
CheckForMultipleOutputs;
CheckForDefinedInputs;
end; {of CheckErrors}
Procedure ReadNodes;
begin
NSAMPLED:=0;
ReadAndParse;
if not Eof(filvar) then
begin
repeat
ReadAndParse;
for I:=0 to 10 do
begin
Xs:=LIs[I];
if Xs<>' ' then
begin
LookUpSignalName;
if FOUND<>-1 then
begin
if NSAMPLED<SCREEN then
begin
NSAMPLED:=NSAMPLED+1;
SAMPLED[NSAMPLED]:=FOUND;
end;
end;
end;
end;
until LIs[0]='END';
for I:=NSAMPLED+1 to SCREEN do
begin
SAMPLED[I]:=0;
end;
end;
end; {of ReadNodes}
Procedure SetUpSimulation;
Label Setup1,Setup2;
begin
if ERROR=0 then
begin
NNAM:=NNAM-1;
NLGIC:=NLGIC-1;
NE:=NE-1;
BuildSelectiveTraceTable;
SetUp1:
InitializeForSimulation;
Setup2:
GetNextScheduledExternal;
MoveNewToOld;
DisplayLogicValues;
if ASK='R' then GOTO Setup1;
if ASK<> 'Q' then
begin
SimulateGates;
RecalculateRippleTime;
GOTO SetUp2;
end;
end;
end;
Procedure ReadInLogicDescription;
begin
SLGIC:=NLGIC; NAMES[0]:='0'; NNAM:=1;
for I:= 1 to MNAMS do
begin
NAMES[I]:='';
end;
repeat
ReadAndParse;
Xs:=LIs[0];
LookUpType;
if FOUND= -1 then AddType;
T[0]:=FOUND;
for I:= 1 to 7 do
begin
Xs:=LIs[I];
LookUpSignalName;
if FOUND= -1 then AddNameToList;
T[I]:= FOUND;
end;
AddT0thruT7toLogicArray;
until T[0]=0;
end; {of ReadInLogicDescription}
Procedure Initialize;
Begin
NLGIC:=0; NTYPE:=14; NPRIM:=13; MX:=MTYPES;
TYPES[0] :='END'; TYPES[1]:='AND'; TYPES[2]:='NAND';
TYPES[3] :='OR'; TYPES[4]:='NOR'; TYPES[5]:='XOR';
TYPES[6] :='XNOR'; TYPES[7]:='DFF'; TYPES[8]:='JKFF';
TYPES[9] :='CNTR'; TYPES[10]:='PLSR'; TYPES[11]:='SREG';
TYPES[12]:='*';
LOGIN[L0]:='0'; LOGPR[L0]:='.'; LNOT[L0]:=L1; LV[L0]:=L0;
LOGIN[L1]:='1'; LOGPR[L1]:='1'; LNOT[L1]:=L0; LV[L1]:=L1;
LOGIN[Lx]:='X'; LOGPR[Lx]:='?'; LNOT[Lx]:=Lx; LV[Lx]:=Lx;
TEX[0]:='A'; TEX[1]:='P';
end; {of initialization }
Procedure CheckForMacroErrors;
begin
Writeln('***** Checking macro ',TYPES[MX],' for Errors');
X1:=TYPEX[MX];
ClearOldArray;
repeat
for I:=1 to 5 do
begin
X:=LO[X1,I];
MarkOutputsAndCheckForDupes;
end;
X1:=X1+1;
X:=LO[X1,0];
until TYPES[X]<>'*';
STF:=X1;
CheckForMultipleOutputs;
CheckForDefinedInputs;
ERROR:=0
end; {of CheckForMacroErrors}
Procedure ReadMacros;
LABEL NextMacro;
begin
NextMacro:
ReadAndParse;
if Copy(LIs[0],1,3) = 'MAC' then
begin
Xs:=LIs[1];
Writeln('***** Reading in macro: ',Xs);
Header:='Macro: '+Xs;
WriteHeader;
TPTR:=-1;
LookUpType;
if FOUND<> -1 then
begin
if TPTR<> -1 then
begin
Writeln('This Macro name Already exists. Should it be replaced?');
Write('(R)eplace, (N)oReplace ');
Readln(ASK); ASK:= ASK+' ';
ASK:= upcase(copy(ASK,1,1));
if ASK<>'R' then
begin
repeat
ReadAndParse;
until LIs[0]='END';
end;
GOTO NextMacro;
end;
end;
TPTR:=NLGIC;
AddType;
MX:=FOUND;
ReadInLogicDescription;
CheckForMacroErrors;
GOTO nextMacro;
end;
end; {of ReadInMacros}
Procedure ExpandMacros;
begin
repeat
STF:=SLGIC; FM:=0;
for I:=STF to NLGIC-1 do
begin
if LO[I,0]>NPRIM then
begin
BuildMacroCorrespondenceArray;
AddExpandedMacroToElementArray;
FM:=1;
end;
end;
until FM=0
end; {of ExpandMacros}
Procedure ListExpansion;
begin
Header:='Expanded Logic Description';
WriteHeader;
Writeln(Device,'TYPE','INPUTS':22,'OUTPUTS':29);
for I:=1 to 5 do
begin
Write(Device,I:8);
end;
Writeln(Device,'Q':8,'Q-':8);
NAMES[0]:=' ';
for I:= SLGIC to NLGIC-1 do
begin
Write(Device,TYPES[LO[I,0]]:8);
for II:= 1 to 7 do
begin
XX:=LO[I,II];
if XX<0 then Write(Device,'#':8,-XX);
if XX>=0 then Write(Device,NAMES[XX]:8);
end;
Writeln(Device);
end;
NAMES[0]:='0';
end; {of ListExpansion}